<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
</head>
<body style="overflow-x:hidden">
<div class="layui-row layui-col-space15">
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-header"><h2>机器学习</h2></div>
            <div class="layui-card-body">
                <button type="button" class="layui-btn site-active" id="learnAction" data-type="loading">开始学习</button>
            </div>
        </div>
    </div>
</div>
<script src="/static/assets/js/jquery.min.js"></script>
<script src="/static/layui/layui.js"></script>
<script>
    layui.use(['element', 'upload', 'layer'], function () {
        let prefix = '/admin';
        let $ = layui.jquery, element = layui.element, layer = layui.layer;
        $('#learnAction').on('click', function () {
            layer.load();
            $.ajax({
                cache: true,
                type: "POST",
                url: prefix + '/learn',
                data: '', // formid
                async: false,
                error: function (request) {
                    layer.closeAll('loading'); //关闭loading
                    layer.alert("操作失败！");
                },
                success: function (data) {
                    if (data.code === 0) {
                        layer.msg("学习完成！", {icon: 1});
                    } else {
                        layer.alert(data.msg)
                    }
                    layer.closeAll('loading'); //关闭loading
                }
            });
        });
    });
</script>
</body>
</html>